package com.kbxwn.logmanager;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.kbxwn.logmanager.entity.EventMessage;
import com.kbxwn.logmanager.entity.HistoryTagAdapter;
import com.kbxwn.logmanager.entity.LogEntity;
import com.kbxwn.logmanager.log.LimitQueue;
import com.kbxwn.logmanager.log.LogManager;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.greenrobot.event.EventBus;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;

public class TestActivity extends Activity {

    @BindView(R.id.condition_listView)
    public ListView historyTagListView;

    private HistoryTagAdapter historyTagAdapter;

    private Handler handler = new Handler();

    private String filterLogTag = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);

        initHistoryTag();
    }

    private void initHistoryTag() {
        historyTagAdapter = new HistoryTagAdapter(this);
        historyTagListView.setAdapter(historyTagAdapter);
        historyTagListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String tag = (String) parent.getItemAtPosition(position);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        historyTagAdapter.onSave();
        EventBus.getDefault().unregister(this);
    }

    protected void hideKeyboard() {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (getCurrentFocus() != null) {
            inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 2);
        }
    }

}
